package com.example.demo.controller;

import com.example.demo.pojo.Result;
import com.example.demo.service.FileUploadService;
import com.example.demo.utils.AliOssUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/file")
public class ImageController {
    @Autowired
    private AliOssUtils aliOssUtils;

//    @Autowired
//    private FileUploadService fileUploadService;

    @PostMapping("/files")
    public Result upload(MultipartFile file) throws Exception {
        String url = aliOssUtils.upload(file);
//        Boolean aBoolean = fileUploadService.fileUpload(url);
//        if (aBoolean)
            return Result.success(url);
//        else
//            return Result.error("图片上传失败",null);
    }
}
